package com.android.signhelper.bean;

import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;

/**
 * Created by ikata on 2018/11/14.
 */

public class Student implements Parcelable{
    private String name;
    private String userName;
    private String password;
    private SignInfo signInfo;
    private String token;
    private String message;

    public Student() {
    }

    public Student(String name, String userName, String password, SignInfo signInfo, String token, String message) {
        this.name = name;
        this.userName = userName;
        this.password = password;
        this.signInfo = signInfo;
        this.token = token;
        this.message = message;
    }

    public Student(String userName, String password) {
        this.userName = userName;
        this.password = password;
    }

    public Student(String userName) {
        this.userName = userName;
    }

    protected Student(Parcel in) {
        name = in.readString();
        userName = in.readString();
        password = in.readString();
        message = in.readString();
        signInfo = in.readParcelable(SignInfo.class.getClassLoader());
        token = in.readString();
    }

    public static final Creator<Student> CREATOR = new Creator<Student>() {
        @Override
        public Student createFromParcel(Parcel in) {
            return new Student(in);
        }

        @Override
        public Student[] newArray(int size) {
            return new Student[size];
        }
    };

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public SignInfo getSignInfo() {
        return signInfo;
    }

    public void setSignInfo(SignInfo signInfo) {
        this.signInfo = signInfo;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(name);
        dest.writeString(userName);
        dest.writeString(password);
        dest.writeString(message);
        dest.writeParcelable(signInfo,flags);
        dest.writeString(token);
    }

    @Override
    public boolean equals(Object obj) {
       if (obj instanceof Student) {
           return getUserName().equals(((Student) obj).getUserName());
       }else {
           return false;
       }
    }
}
